package receivesms.example;

import android.app.ListActivity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.SimpleCursorAdapter;

public class ReceiveSMSExampleActivity extends ListActivity {
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		// Cargamos la lista de mensajes recibidos
		Uri uri = Uri.parse("content://sms/sent");
		Cursor cursor = getContentResolver().query(uri, null, null, null, null);
		startManagingCursor(cursor);
		// Relacionamos las columnas con la vista
		String[] columns = new String[] { "address", "body" };
		int[] names = new int[] { android.R.id.text1, android.R.id.text2 };
		// Usamos un adapter del sistema 
		SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, columns, names);
		// Lo asociamos con la Activity
		setListAdapter(adapter);
		
	}
}